package acwing.位运算;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 笨拙的手指
 *
 * @author yang
 * @date 2022/1/3
 */
public class 笨拙的手指 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] a = sc.nextLine().toCharArray();
        char[] b = sc.nextLine().toCharArray();

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < a.length; i++) {
            a[i] ^= 1;

            list.add(get(a,2));
            a[i] ^= 1;
        }

        for (int i = 0; i < b.length; i++) {
            char t = b[i];
            for (int j = 0; j < 3; j++) {
                if (t - '0' != j) {
                    b[i] =(char) (j + '0');
                    int x = get(b,3);
                    if (list.contains(x)) {
                        System.out.println(x);
                        return;
                    }
                }
            }
            b[i] = t;
        }
    }

    private static Integer get(char[] a, int i) {

        int res = 0;
        for (char c : a) {
            res = res * i + c - '0';
        }
        return res;
    }
}
